package jun.empdepmanagersystem02.controller;


import jun.empdepmanagersystem02.pojo.QiNiuYun;
import jun.empdepmanagersystem02.pojo.Result;
import jun.empdepmanagersystem02.until.QiniuYununtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

@Slf4j
@RestController
@RequestMapping("/upload")
public class ImgUploadController {
    @Autowired
    private QiNiuYun qiNiuYun;

    @PostMapping
    public Result upload(MultipartFile image) throws IOException {

        String Url = QiniuYununtils.upload(qiNiuYun, image.getBytes(), image.getOriginalFilename());

        return Result.success(Url);
    }


}
